<ion-header>
    <ion-toolbar>
        <ion-buttons start>
            <button ion-button icon-left *ngIf="(segmentType === '2' || empnamesId.length <= 0 ) && stackData.length>0"
                    (click)="goBack()">
                <ion-icon name="arrow-back"></ion-icon>
                上一级
            </button>
            <button ion-button (click)="dismiss()" *ngIf="stackData.length==0 || segmentType === '1'">取消</button>
        </ion-buttons>
        <ion-title>
          <div *ngIf="segmentType ==='2' && empnamesId.length <= 0">组织树</div>
          <ion-item *ngIf="empnamesId.length > 0" class="segmentType">
            <ion-select cancelText="取消" okText="确定" [(ngModel)]="segmentType" *ngIf="empnamesId.length > 0">
              <ion-option value="1">预置人员</ion-option>
              <ion-option value="2">组织树</ion-option>
            </ion-select>
          </ion-item>
        </ion-title>
        <ion-buttons end>
            <button ion-button (click)="complete()" strong>完成</button>
        </ion-buttons>
    </ion-toolbar>
    <ion-toolbar no-border-top *ngIf="segmentType ==='2' || empnamesId.length <= 0">
        <ion-searchbar autofocus="true" [(ngModel)]="queryText" (ionInput)="updateList()" placeholder="输入首字母拼音或者中文进行搜索人">
        </ion-searchbar>
    </ion-toolbar>
  <!--<ion-segment class="header_segment" [(ngModel)]="segmentType" *ngIf="empnamesId.length > 0">
    <ion-segment-button value="1">
      <span>预置人员</span>
    </ion-segment-button>
    <ion-segment-button value="2">
      <span>组织树</span>
    </ion-segment-button>
  </ion-segment>-->
</ion-header>
<ion-content class="outer-content">
    <ion-list class="first-layer" *ngIf="segmentType === '2' || empnamesId.length <= 0">
      <ion-item *ngIf="empnamesId.length > 0">
        &nbsp;
      </ion-item>
        <div *ngFor="let item of listData">
            <ion-item>
                <ion-row>
                    <ion-col width-10 *ngIf="isSelectUser?(item.empid?true:false):true">
                        <input type="checkbox" [checked]="item.isSelected" (change)="onChange(item,null)">
                    </ion-col>
                    <ion-col width-90 (click)="expand('top',item)">
                        {{item.name}}
                        <!-- <ion-note item-right>
                            {{item.empid?item.titlename:''}}
                        </ion-note> -->
                        <ion-icon *ngIf="!item.isShowSub&&item.subList" name="arrow-forward"></ion-icon>
                        <ion-icon *ngIf="item.isShowSub&&item.subList" name="arrow-down"></ion-icon>
                    </ion-col>
                </ion-row>
            </ion-item>
            <ion-list class="second-layer" [hidden]="!item.isShowSub" *ngFor="let subItem of item.subList">
                <ion-item>
                    <ion-row>
                        <ion-col width-10 *ngIf="isSelectUser?(subItem.empid?true:false):true">
                            <input type="checkbox" [checked]="subItem.isSelected" (change)="onChange(subItem,null)">
                        </ion-col>
                        <ion-col width-90 (click)="expand('sub',subItem)">
                            {{subItem.name}}
                            <ion-icon name="arrow-forward" *ngIf="subItem.subList"></ion-icon>
                        </ion-col>
                    </ion-row>
                </ion-item>
            </ion-list>
        </div>
    </ion-list>

    <ion-list class='gfoa-list' *ngIf="segmentType === '1'">
      <div *ngFor="let item of empList; let i = index;">
        <ion-item *ngIf="item && item.empname">
          <ion-row (click)="selectChange(i)">
            <ion-col width-10>
              <ion-icon name="radio-button-off" *ngIf="!item.isChecked"></ion-icon>
              <ion-icon name="checkmark-circle" *ngIf="item.isChecked" color="primary"></ion-icon>
            </ion-col>
            <ion-col>
              {{item.empname}}
            </ion-col>
          </ion-row>
        </ion-item>
      </div>
    </ion-list>

    <div class="selected-contact-content">
        <p>已经选择：</p>
        <div color="light" class="selected-contact-item" *ngFor="let item of selectedList">
            {{!item.empid?item.full_orgname:(item.full_orgname ? item.full_orgname + "/" + item.name : item.name)}}
            <ion-icon name="close-circle" (click)="removeSelectedItem(item)"></ion-icon>
        </div>
    </div>
</ion-content>
<!-- <ion-footer>
    <ion-scroll scrollX="true">
        <ion-row>
            <div color="light" class="selected-item" *ngFor="let item of selectedList">
                {{item.name}}
                <ion-icon name="close-circle" (click)="removeSelectedItem(item)"></ion-icon>
            </div>
        </ion-row>
    </ion-scroll>
</ion-footer> -->
